package display.scenes
{
	import display.ImageSlot;
	import display.TalkPanel;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.filters.DisplacementMapFilter;
	import flash.geom.Rectangle;
	import flash.utils.Dictionary;
	
	import slices.FadeInDisplayObject;
	import slices.TimeSlice;
	import globals.$athena;
	import display.Scene;
	
	public class TalkScene extends Scene
	{
		public var bg:ImageSlot;
		public var charLayer:Sprite;
		public var textPanel:TalkPanel;
		public var chars:Dictionary = new Dictionary();
		public var fontID:Object;
		public var exps:Dictionary = new Dictionary();
		
		public function TalkScene(w:int, h:int)
		{
			super();
			bg = new ImageSlot;
			charLayer = new Sprite();
			textPanel = new TalkPanel();
			var bound:Rectangle = textPanel.getBounds(textPanel);
			textPanel.x = w/2-bound.width/2;
			textPanel.y = 514;
			addChild(bg);
			addChild(charLayer);
			addChild(textPanel);
		}
		
		public function findChar(id:Object):DisplayObject {
			return chars[id];
		}
		
		public function addChar(id:Object, express:int, dob:DisplayObject):void {
			charLayer.addChild(dob);
			chars[id] = dob;
			exps[id] = express;
		}
		
		public function clear():void {
			textPanel.clear();
		}
		
		public function changeToBackGround(v:Bitmap, fadeSpeed:Number=0.1):TimeSlice {
			return bg.changeTo(v, fadeSpeed, fadeSpeed);
		}
		
		public function setBackGround(v:DisplayObject):void {
			v.width = 1280;
			v.height = 720;
			if (v is Bitmap) {
				(v as Bitmap).smoothing = true;
			}			
			bg.setContent(v);
//			bg.changeTo(v, 1, 1);
		}
		
		public function showTalker():void {
			
		}
		
		public function talk(text:String, from:String):TimeSlice {
			return null;
		}
	}
}